package com.shop.common.entity;

/**
 * @author ghy
 * @version 1.0
 * @date 2020-10-29
 */
import com.shop.common.constant.MessageConstant;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class CommonResult<T> implements Serializable {

    /**
     * 是否成功
     *  true : 代表成功
     *  false : 代表失败
     */
    private Boolean isSuccess  = true;

    /**
     * 返回消息
     *  成功 : "success"
     *  失败 : "fail"
     */
    private String message;

    /**
     * 附加数据
     */
    private T data;

    public CommonResult(Boolean isSuccess, String message) {
        this.isSuccess = isSuccess;
        this.message = message;
    }

    public CommonResult(T data) {
        this.data = data;
    }

    public CommonResult(String message, T data) {
        this.isSuccess = true;
        this.message = message;
        this.data = data;
    }
}
